package com.neusoft.elmboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.Cart;
import com.neusoft.elmboot.po.DeliveryAddress;
import com.neusoft.elmboot.po.Food;
import com.neusoft.elmboot.service.FoodService;

@RestController
@RequestMapping("/foods")
public class FoodController {
	
	@Autowired
	private FoodService foodService;

	@GetMapping("/businesses/{businessId}")
	public List<Food> listFoodByBusinessId(Food food) throws Exception{
		return foodService.listFoodByBusinessId(food.getBusinessId());
	}
	
	@DeleteMapping("/{foodId}")
	public int removeFoodByBusinessId(Food food) throws Exception{
		return foodService.removeFoodByBusinessId(food.getFoodId());
	} 
	
	@PostMapping("")
	public int saveFood(Food food) throws Exception {
		return foodService.saveFood(food);
	}
	

	@PutMapping("/{foodId}")
	public int updateFood(Food food) throws Exception{
		return foodService.updateFood(food);
	}
	
	/*
	@GetMapping("")
	public List<Food> listFood(Food food) throws Exception{
		return foodService.listFoodByBusinessId(food.getBusinessId());
	}
	*/
}
